from .celery import app
from common.utils.telegram_proxy import send_text_message_to_group


@app.task
def send_exception_to_group(exception, request):
    format_string = 'catch error\n{} \nin {}, \nuid:{}'
    send_text_message_to_group(format_string.format(
        exception.__class__.__name__, request.path,
        request.user_id if hasattr(request, 'user_id') else None))


@app.task
def send_error_message_to_group(message):
    send_text_message_to_group(message)
